using System;
using System.Data;


public partial class Contacts : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            int id;
            int.TryParse(Request.QueryString["id"], out id);
            
            tenderSmall.tenderSmallTableDataTable tender = new tenderSmall.tenderSmallTableDataTable();

            tenderSmallTableAdapters.tenderSmallTableTableAdapter tenderAdapter =
                new tenderSmallTableAdapters.tenderSmallTableTableAdapter();

            tenderAdapter.Fill(tender);

            AvailTenders.DataSource = tender;
            AvailTenders.DataBind();
            
            TenderList.DataSource = tender;
            TenderList.DataBind();

            DataRow[] rows = tender.Select("id=" + id);
            if (rows.Length > 0)
            {
                int rowId = (int)rows[0]["id"];
                for (int i = 0; i < tender.Rows.Count; i++)
                {
                    if (rowId == (int)tender.Rows[i]["id"])
                    {
                        TenderList.SelectedIndex = i;
                        break;
                    }
                }
            }
            else
            {
                if (tender.Rows.Count>0)
                    TenderList.SelectedIndex = 0;
            }
        }
        else
        {
            
        }
    }
}
